(function(doc){
	function $(id){
		return doc.getElementById(id);
	}
	function autoSubmit(){
		var orderEls = doc.querySelectorAll('.ksorder_kyy');
		if(orderEls.length>0){
			var orderEl = orderEls[orderEls.length-1];
			orderEl.click();
			setTimeout(login.bind(null, orderEl.click.bind(null, orderEl)), 100);
		}
	}
	
	function login(next){
		var loginDialog = $('djdl');
		console.log("display:  " + loginDialog.style.display)
		if(loginDialog && loginDialog.style.display==='block'){
			var mobile = $('mobileQuickLogin');
			var password = $('pwQuickLogin');
			mobile.value='';
			password.value='';
			$('quick_login').click();
			setTimeout(next, 100);
		}
	}
	
	if(doc.readyState === "complete" && doc.body){
		autoSubmit();
	}else{
		doc.addEventListener('DOMContentLoaded', autoSubmit, false);
	}
})(document)

